package Demo_01;

public class Thread_02 {
    public static void main(String[] args) {

    }
    public static void main1(String[] args) {
        Thread th = new Thread(() -> {
             while(true) {
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                     System.out.println("休眠被终止 ...");
                     break;
                 }
                 System.out.println("我在执行...");
             }
        });
        th.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("快终止线程！！");
        th.interrupt();
    }
}
